# def isValidSudoku(self, board: List[List[str]]) -> bool:
def isValidSudoku(board):
    result = []
    for i in range(9):
        result.clear()
        for j in range(9):
            item = board[i][j]
            if item == ".":
                continue
            if item in result:
                return False
            else:
                result.append(item)
    for i in range(9):
        result.clear()
        for j in range(9):
            item = board[j][i]
            if item == ".":
                continue
            if item in result:
                return False
            else:
                result.append(item)
    area = [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
    for ms in area:
        for ns in area:
            result.clear()
            for m in ms:
                for n in ns:
                    if board[m][n] == ".":
                        continue
                    if board[m][n] in result:
                        return False
                    else:
                        result.append(board[m][n])
    return True



def main():
    boards = [
        [
            ["5","3",".",".","7",".",".",".","."],
            ["6",".",".","1","9","5",".",".","."],
            [".","9","8",".",".",".",".","6","."],
            ["8",".",".",".","6",".",".",".","3"],
            ["4",".",".","8",".","3",".",".","1"],
            ["7",".",".",".","2",".",".",".","6"],
            [".","6",".",".",".",".","2","8","."],
            [".",".",".","4","1","9",".",".","5"],
            [".",".",".",".","8",".",".","7","9"]
        ], 
        [
            ["8","3",".",".","7",".",".",".","."],
            ["6",".",".","1","9","5",".",".","."],
            [".","9","8",".",".",".",".","6","."],
            ["8",".",".",".","6",".",".",".","3"],
            ["4",".",".","8",".","3",".",".","1"],
            ["7",".",".",".","2",".",".",".","6"],
            [".","6",".",".",".",".","2","8","."],
            [".",".",".","4","1","9",".",".","5"],
            [".",".",".",".","8",".",".","7","9"]
        ],
        [
            [".",".","4",".",".",".","6","3","."],
            [".",".",".",".",".",".",".",".","."],
            ["5",".",".",".",".",".",".","9","."],
            [".",".",".","5","6",".",".",".","."],
            ["4",".","3",".",".",".",".",".","1"],
            [".",".",".","7",".",".",".",".","."],
            [".",".",".","5",".",".",".",".","."],
            [".",".",".",".",".",".",".",".","."],
            [".",".",".",".",".",".",".",".","."]
        ],
        [
            [".",".",".",".","5",".",".","1","."],
            [".","4",".","3",".",".",".",".","."],
            [".",".",".",".",".","3",".",".","1"],
            ["8",".",".",".",".",".",".","2","."],
            [".",".","2",".","7",".",".",".","."],
            [".","1","5",".",".",".",".",".","."],
            [".",".",".",".",".","2",".",".","."],
            [".","2",".","9",".",".",".",".","."],
            [".",".","4",".",".",".",".",".","."]
        ]
    ] 
    for board in boards:
        print(isValidSudoku(board))


if __name__ == "__main__":
    main()